<script language="javascript">
function validate_form(thisform)
{
with (thisform)
{
	
	
	if (validate_required(txtmonth,"Bạn chưa chọn tháng !")==false)
 	{txtmonth.focus();return false;}
	
	if (validate_required(txtyear,"Bạn chưa chọn năm !")==false)
 	{txtyear.focus();return false;}
	if (validate_required(nhanvien,"Bạn chưa chọn nhân viên !")==false)
 	{nhanvien.focus();return false;}
	

}
}
</script>
<table class="box-vang5" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr class="light">
          <td class="text-top">.:. Dự án đã hoàn thành</td>
        </tr>
      </tbody></table>
      <table class="box-vang5" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr class="light">
          <td class="t-l"></td>
          <td class="t-c"></td>
          <td class="t-r"></td>
        </tr>
        <tr class="light">
          <td class="c-l"></td>
          <td class="c-c" valign="top">
         
<div class="clear" style="height:10px"></div>
<form method="post" action="" onsubmit="return validate_form(this);">
     <p>Xem công việc đã hoàn thành<span>
     	<select name="txtmonth"> 
        	<option value="">--Chọn tháng--</option>
            <option value="01" <?php if($_POST['txtmonth']==1){?> selected="selected" <?php }?>> 01 </option>
            <option value="02" <?php if($_POST['txtmonth']==2){?> selected="selected" <?php }?>> 02 </option>
            <option value="03" <?php if($_POST['txtmonth']==3){?> selected="selected" <?php }?>> 03 </option>
            <option value="04" <?php if($_POST['txtmonth']==4){?> selected="selected" <?php }?>> 04 </option>
            <option value="05" <?php if($_POST['txtmonth']==5){?> selected="selected" <?php }?>> 05 </option>
            <option value="06" <?php if($_POST['txtmonth']==6){?> selected="selected" <?php }?>> 06 </option>
            <option value="07" <?php if($_POST['txtmonth']==7){?> selected="selected" <?php }?>> 07 </option>
            <option value="08" <?php if($_POST['txtmonth']==8){?> selected="selected" <?php }?>> 08 </option>
            <option value="09" <?php if($_POST['txtmonth']==9){?> selected="selected" <?php }?>> 09 </option>
            <option value="10" <?php if($_POST['txtmonth']==10){?> selected="selected" <?php }?>> 10 </option>
            <option value="11" <?php if($_POST['txtmonth']==11){?> selected="selected" <?php }?>> 11 </option>
            <option value="12" <?php if($_POST['txtmonth']==12){?> selected="selected" <?php }?>> 12 </option>
        </select>
    </span> 
    <span>Năm </span> 
    <span> 
    	<select name="txtyear"> 
        	<option value="">--Chọn năm--</option>
            <option value="2012" <?php if($_POST['txtyear']==2012){?> selected="selected" <?php }?>>2012 </option>
            <option value="2013" <?php if($_POST['txtyear']==2013){?> selected="selected" <?php }?>>2013 </option>
            <option value="2014" <?php if($_POST['txtyear']==2014){?> selected="selected" <?php }?>>2014 </option>
            <option value="2015" <?php if($_POST['txtyear']==2015){?> selected="selected" <?php }?>>2015 </option>
            <option value="2016" <?php if($_POST['txtyear']==2016){?> selected="selected" <?php }?>>2016 </option>
            <option value="2017" <?php if($_POST['txtyear']==2017){?> selected="selected" <?php }?>>2017 </option>
            <option value="2018" <?php if($_POST['txtyear']==2018){?> selected="selected" <?php }?>>2018 </option>
            <option value="2019" <?php if($_POST['txtyear']==2019){?> selected="selected" <?php }?>>2019 </option>
            <option value="2020" <?php if($_POST['txtyear']==2020){?> selected="selected" <?php }?>>2020 </option>
        </select>
    </span> 
    <?php if($_SESSION['level']==2 or $_SESSION['level']==3){?>
    &nbsp;&nbsp;
    |
    &nbsp;&nbsp;
    <span>Nhân viên </span> 
    <span> 
    	<select name="nhanvien"> 
        	<option value="">--Chọn nhân viên--</option>
            <?php 
				$sqlnhanvien=mysql_query("select * from tb_account_admin where level!=3");
				while($rsnhanvien=mysql_fetch_array($sqlnhanvien))
				{
			?>
            <option value="<?php echo $rsnhanvien['account_id'];?>" <?php if($_POST['nhanvien']==$rsnhanvien['account_id']){?> selected="selected" <?php }?>><?php echo $rsnhanvien['account_name'];?></option>
           <?php }?>
        </select>
    </span> 
    <?php }?>
    &nbsp;
    <span><input name="button" type="submit" value="Tìm kiếm" class="cs-title-timkiem"/></span>
    &nbsp;&nbsp;
    	
    </p>
    
    </form>
<div class="clear" style="height:10px"></div>
<?php 
	$txtmonth=$_POST['txtmonth'];
	$txtyear=$_POST['txtyear'];
	$nhanvien=$_POST['nhanvien'];
?>
<?php 
	
	$user=$_SESSION['userid'];
	$name=$_SESSION['name'];
	if($_SESSION['level']==2 or $_SESSION['level']==3)
	{
	$sqlstring=" select
						tb_task.task_id,
						tb_task.task_name,
						tb_task.contract_start,
						tb_task.contract_end,
						tb_task.level as mucdo,
						tb_task.brief,
						tb_task.file_attach,
						tb_task.sender,
						tb_task.nguoinhan,
						tb_task.nguoitiepnhan,
						tb_task.date_creative,
						tb_task.tiendo,
						tb_task.status,
						tb_account_admin.account_name
				from 
					tb_task
					inner join tb_account_admin on tb_task.nguoinhan=tb_account_admin.account_id
				where  status=2";
	}
	else
	{
		$sqlstring=" select
						tb_task.task_id,
						tb_task.task_name,
						tb_task.contract_start,
						tb_task.contract_end,
						tb_task.level as mucdo,
						tb_task.brief,
						tb_task.file_attach,
						tb_task.sender,
						tb_task.nguoinhan,
						tb_task.nguoitiepnhan,
						tb_task.date_creative,
						tb_task.tiendo,
						tb_task.status,
						tb_account_admin.account_name
				from 
					tb_task
					inner join tb_account_admin on tb_task.nguoinhan=tb_account_admin.account_id
				where (nguoinhan='$user' or nguoitheodoi like '%$name%') and status=2";
	}
	$sqlstring2="	select
						tb_task.task_id,
						tb_task.task_name,
						tb_task.contract_start,
						tb_task.contract_end,
						tb_task.level as mucdo,
						tb_task.brief,
						tb_task.file_attach,
						tb_task.sender,
						tb_task.nguoinhan,
						tb_task.nguoitiepnhan,
						tb_task.date_creative,
						tb_task.tiendo,
						tb_task.status,
						tb_account_admin.account_name
					from 
					tb_task
					inner join tb_account_admin on tb_task.nguoinhan=tb_account_admin.account_id
								";
	$sqlstring3=" select
						tb_task.task_id,
						tb_task.task_name,
						tb_task.contract_start,
						tb_task.contract_end,
						tb_task.level as mucdo,
						tb_task.brief,
						tb_task.file_attach,
						tb_task.sender,
						tb_task.nguoinhan,
						tb_task.nguoitiepnhan,
						tb_task.date_creative,
						tb_task.tiendo,
						tb_task.status,
						tb_account_admin.account_name
					from 
					tb_task
					inner join tb_account_admin on tb_task.nguoinhan=tb_account_admin.account_id
								";
	
	if($_SESSION['level']!==2 and $_SESSION['level']!==3)
	{
		if($txtmonth!="" and $txtyear!=""){$sqlstring2.=" and FROM_UNIXTIME(tb_task.contract_end,'%m') like '%$txtmonth%' and FROM_UNIXTIME(tb_task.contract_end,'%Y') like '%$txtyear%' and tb_task.status=2 and tb_task.nguoinhan='$user'";}
		if($txtmonth!="" and $txtyear!="")
		{
		$sql=mysql_query($sqlstring2);
		}
		else
		{
			$sql=mysql_query($sqlstring);
		}
	}
	if($_SESSION['level']==2 or $_SESSION['level']==3)
	{
		if($txtmonth!="" and $txtyear!="" and $nhanvien!="")
		{
			$sqlstring3.=" and FROM_UNIXTIME(tb_task.contract_end,'%m') like '%$txtmonth%' and FROM_UNIXTIME(tb_task.contract_end,'%Y') like '%$txtyear%' and tb_task.nguoinhan = '$nhanvien' and tb_task.status=2";
		}
		if($txtmonth!="" and $txtyear!="" and $nhanvien!="")
		{
			$sql=mysql_query($sqlstring3);
		}
		
	}
	
	$sql1=mysql_query($sqlstring);
	$n_record=mysql_num_rows($sql1); 
	$p=$_SESSION['page'];
	$n=$_GET['n'];
	
	$sql=mysql_query($sqlstring);
?>
 
<table id="box-quick" class="box-quick" border="0" cellpadding="5" cellspacing="0" width="100%">
          <tbody><tr id="title">
            <td width="5%">Mã </td>
            <td width="30%">Tên dự án</td>
            <td width="10%">Mức độ ưu tiên</td>
            <td width="10%">Ngày bắt đầu</td>
             <td width="10%">Ngày kết thúc</td>
            <td width="10%">Ngày gửi dự án</td>
            <td width="10%">Giao cho </td>
            <td width="15%">Trạng thái</td>
          </tr>
         <?php 
		 	while($row=mysql_fetch_array($sql))
			{
				
		 ?>
           <tr class="light" id="value" style="cursor:pointer;" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)" bgcolor="">
            <td style="border-left:1px solid #ccc"><div align="center"><?php echo $row['task_id'];?></div></td>
          
            <td  class="tdbg_2" onclick="window.open('index.php?tn=task_detail&id=<?php echo $row['task_id'];?>','_self');"><div align="left">&nbsp;<span title="<?php echo $row['task_name'];?>">
				<?php echo $row['task_name'];?>
                 </span>
                </div>
            </td>
           
            <td>
            	<div align="center" style="color:#090;">
					<?php if($row['mucdo']==1){echo 'Thấp';}?>
                    <?php if($row['mucdo']==2){echo 'Trung bình';}?>
                    <?php if($row['mucdo']==3){echo 'Cao';}?>
            	</div>
            </td>
             <td align="center"> <?php echo date('d-m-Y',$row['contract_start']);?> </td>
            <td align="center"> <?php echo date('d-m-Y',$row['contract_end']);?> </td>
             <td><div align="center">&nbsp;<?php echo date('d-m-Y',$row['date_creative']);?></div></td>
             <td align="center"><?php echo $row['account_name'];?> </td>
             <td align="center">
             	<?php if($row['status']==2){echo '<span style="color:#00F">Đã hoàn thành</span>';}?>
              
             </td>
          </tr>
          
         <?php }?>
         
          
        </tbody></table>
        <div style="margin-top:20px;"><?php //view_page('index.php?tn=project_complete'); ?></div>
       
 <td class="c-r"></td>
        </tr>
        <tr class="light">
          <td class="b-l"></td>
          <td class="b-c"></td>
          <td class="b-r"></td>
        </tr>
      </tbody></table>